package ml.evaluation;

import java.util.List;

import ml.UpAndCountDownLatch;
import weka.classifiers.trees.RandomForest;
import weka.core.Instances;

public class RandomForestClassification extends EvaluationRunnable {
	private final int numTrees;
	private final int maxDepth;

	public RandomForestClassification(UpAndCountDownLatch latch,
			Instances trainingData, Instances testData,
			List<EvaluationResult> results, int numTrees, int maxDepth) {
		super(latch, trainingData, testData, results);
		this.numTrees = numTrees;
		this.maxDepth = maxDepth;
	}

	@Override
	public EvaluationResult evaluate() throws Exception {
		System.out
				.println(String
						.format("Execution of RandomForest (numTrees: %d, maxDepth: %d) classification evaluation started ...",
								numTrees, maxDepth));
		RandomForest randForest = new RandomForest();
		randForest.setNumTrees(numTrees);
		randForest.setMaxDepth(maxDepth);
		return evaluateOnTestData(randForest);
	}
}
